package insigne.kernel.sgbdinterface.basics;


import java.sql.SQLException;
import java.sql.ResultSet;

public class Listeinsignes extends DBOperator{

	/* ############################### Fields ############################### */
	private int IDListe;

	private java.sql.Date Date;
	
	private int IDFaluchard;

	

	/* ############################### Getters ############################## */
	public int getIDListe(){
		return IDListe;
	}

	public java.sql.Date getDate(){
		return Date;
	}

	public int getIDFaluchard() {
		return IDFaluchard;
	}
	/* ############################### Setters ############################## */
	public void setIDListe(int newValue){
		this.IDListe = newValue;
	}

	public void setDate(java.sql.Date newValue){
		this.Date = newValue;
	}
	
	public void setIDFaluchard(int newValue) throws SQLException{
		openConnection();
		this.IDFaluchard = newValue;
		executeUpdate("UPDATE listeinsignes SET  `IDFaluchard` =  '"+newValue+"' WHERE  IDListe='"+IDListe+"'");
		con.close();
	}

	/* ########################### CLASS CONSTRUCTORS ####################### */
	/** ATTENTION LA DATE NE SERT A RIEN, LA DATE INSEREE EST LA DATE ACTUELLE */
	public Listeinsignes(java.sql.Date Date, int IDFaluchard) throws SQLException {
		openConnection();
		this.Date = Date;
		this.IDFaluchard = IDFaluchard;
		this.IDListe = executeUpdate("INSERT INTO listeinsignes VALUES('DEFAULT',CURRENT_TIMESTAMP(), " + IDFaluchard + ")");
		con.close();
	}

	public Listeinsignes(int IDListe) throws SQLException {
		openConnection();
		ResultSet rs = executeSelect("SELECT * FROM listeinsignes WHERE IDListe='"+IDListe+"'");
		rs.next();
		this.IDListe = rs.getInt("IDListe");
		this.Date = rs.getDate("Date");
		this.IDFaluchard = rs.getInt("IDFaluchard");
		con.close();
	}
}